package com.hdc.sell.utils.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Date;

/**
 * @author 郭丽然
 * @program: sell
 * @date 2020/5/23 22:00
 * 功能：
 */
public class Date2LongSerializer extends JsonSerializer<Date> {
    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
        try {
            jsonGenerator.writeNumber(date.getTime()/1000);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
